using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace GameStateManagement
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public abstract class PowerUp : OrbitingActor
    {
        protected string type;
        protected bool currentlyDisplayed = false;
        protected Utils.Timer abilityCounter = new Utils.Timer();
        float m_fMagnitudeRatio;

       public PowerUp(Game game, float magnitudeRatio, float speed)
            :base(game)
        {
            sMeshName = "Checkpoint";
            m_fScale = 3.0f;
            
            // Physics
            fMass = 1.0f;
            fTerminalVelocity = 100.0f;
            vAcceleration = Vector3.Zero;
            bPhysicsDriven = true;
            currentlyDisplayed = false;

            m_fSpeed = speed;
            m_fMagnitudeRatio = magnitudeRatio;

            m_qRotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.PiOver2);
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            // Make all power-ups affected by blackholes
            WormholeManager.GetWormholeManager().AddToScope(this);

            base.Initialize();
        }
        public override void Draw(GameTime gameTime)
        {
            if (currentlyDisplayed)
            {
                base.Draw(gameTime);
            }
        }
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            if (!GameplayScreen.pause && !GameplayScreen.gameOver)
            {
                // Scale the radius to the shrinking sphere.
                ScaleRadiusBetweenSphereAndPlanet(m_fMagnitudeRatio);

                // Rotate powerup.
                m_qRotation *= Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), (float)Math.PI * 0.5f * (float)gameTime.ElapsedGameTime.TotalSeconds);

                base.Update(gameTime);
            }
        }
        new public string GetType()
        {
        return type;
        }
        public void SetDisplayed(Boolean passedBool)
        {
            currentlyDisplayed = passedBool;
        }
        public Boolean GetDisplayed()
        {
            return currentlyDisplayed;
        }
        public abstract void UseAbility(Player passedShip);
    }
}
